var currentResultPanel = 0;

var searchTypes = new Array('Translation', 'Web', 'MobileWeb', 'News', 'Image', 'Video');
var searchFilter = null;
var pendingSearches = new Array(0, 0, 0, 0, 0);
var searchPerPage = 10;
var searchQuery = null;

function doSearch()
{
	var query = $('search_text').value;
	
	if(query.length > 0)
	{
		searchQuery = query;
		
		searchBing(query, getFilteredTyped(), searchHandler);
	}
	else
	{
		showError('Please specify a search text');
	}
}
function getFilteredTyped()
{
	var filtered = new Array();
	
	for(var i = 0; i < searchTypes.length; i++)
	{
		if(searchFilter[i] == 1)
			filtered.push(searchTypes[i]);
	}
	return filtered;
}
function gotoPage(page, type)
{
	if(searchQuery != null)
	{
		searchBing(searchQuery, type, gotoPageHandler, page);
	}
}
function gotoPageHandler(json, types)
{
	showResults(json, types, 0);
}

function searchHandler(json, types)
{
	showResults(json, types, 0);
}
function tabHandler(tabIndex)
{
	$('result_panel_' + searchTypes[currentResultPanel]).style.display = 'none';
	
	currentResultPanel = tabIndex;
	
	$('result_panel_' + searchTypes[currentResultPanel]).style.display = '';
}
